import pandas as pd
import pymysql
from sqlalchemy import create_engine

# # CSV
# data = pd.read_csv("stock_day.csv", usecols=["open", "close"])
# data.to_csv("test.csv", columns=["close"], index=False, mode="w")  # index=False代表写入时不写入索引，默认为index=True即写入
#
# # JSON
# data = pd.read_json("Sarcasm_Headlines_Dataset.json", orient="records", lines=True)
# data.to_json("test.json", orient="records", lines=True)

# # EXCEL
# df = pd.DataFrame({'month': [1, 4, 7, 10],
#                    'year': [2012, 2014, 2013, 2014],
#                    'sale': [55, 40, 84, 31]})
# df.to_excel("sale.xlsx", sheet_name="销售额")
# pd.read_excel("sale.xlx", sheet_name="销售额")

# SQL
# engine = create_engine("mysql+pymysql://root:@127.0.0.1/ems")
# df = pd.read_sql("meeting", engine)
# print(df)
# df2 = pd.read_sql("select * from meeting where id = 13", engine)
# print(df2)
# # 向 meeting 表中插入数据，如果表存在则追加 append，不存在则新建
# df.tosql("meeting", engine, if_exists="append")
